import { stringify } from 'qs';
import request from '../utils/request';
import apiURL from '../utils/urlConfig';
import { getAuthority } from '../utils/authority';

export async function queryProjectNotice() {
  return request('/api/project/notice');
}

export async function queryActivities() {
  return request('/api/activities');
}

export async function queryRule(params) {
  return request(`/api/rule?${stringify(params)}`);
}
// export async function userInfo(params) {
//   return request(`/api/user/details/${params}`);
// }

export async function removeRule(params) {
  return request('/api/rule', {
    method: 'POST',
    body: {
      ...params,
      method: 'delete',
    },
  });
}

export async function addRule(params) {
  return request('/api/rule', {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    },
  });
}

export async function fakeSubmitForm(params) {
  return request('/api/forms', {
    method: 'POST',
    body: params,
  });
}

export async function fakeChartData() {
  return request('/api/fake_chart_data');
}

export async function queryTags() {
  return request('/api/tags');
}

export async function queryBasicProfile() {
  return request('/api/profile/basic');
}

export async function queryAdvancedProfile() {
  return request('/api/profile/advanced');
}
export async function queryAdminList(params) {
  return request(`/api/v2/users?${stringify(params)}`);
}
export async function queryFakeList(params) {
  return request(`/api/fake_list?${stringify(params)}`);
}

export async function getUserMenu() {
  return request(apiURL.api.getAdminUserMenu, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function queryRoleList() {
  return request(apiURL.api.getRoleList, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function fakeAccountLogin(params) {
  return request(apiURL.api.login, {
    method: 'POST',
    body: {
      password: params.password,
      username: params.username,
    },
  });
}

export async function fakeRegister(params) {
  return request('/api/register', {
    method: 'POST',
    body: params,
  });
}
//控制台
export async function userInfo() {
  return request(apiURL.api.userInfo, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function queryNotices() {
  return request('/api/notices');
}
export function queryUserMenus() {
  return request('/user/role');
}
export function queryUser(params) {
  return request(`/api/user/${params}`, {
    method: 'GET',
    body: params,
  });
}
export function userLogout() {
  return request('/api/user/logout', {
    method: 'GET',
  });
}

export async function querySysUserList(params) {
  return request(apiURL.api.getSysUserList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function addSysUser(params) {
  return request(apiURL.api.addSysUser, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function updateSysUser(params) {
  return request(apiURL.api.updateSysUser, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function updateSysUserStatus(params) {
  return request(apiURL.api.updateSysUserStatus, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getSysUserInfo(params) {
  return request(`${apiURL.api.getSysUserInfo}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function queryUserList(params) {
  return request(apiURL.api.getUserList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function checkUser(params) {
  return request(apiURL.api.checkUser, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getUserInfo(params) {
  return request(`${apiURL.api.getUserInfo}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function updateUser(params) {
  return request(apiURL.api.updateUser, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}


export async function updateMasterStatus(params) {
  return request(apiURL.api.updateMasterStatus, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function queryMasterList(params) {
  return request(apiURL.api.getMasterList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function updateMaster(params) {
  return request(apiURL.api.updateMaster, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function addMaster(params) {
  return request(apiURL.api.addMaster, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getMasterInfo(params) {
  return request(`${apiURL.api.getMasterInfo}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function deleteMaster(params) {
  return request(`${apiURL.api.deleteMaster}/${params.id}`, {
    method: 'DELETE',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function changeMasterPwd(params) {
  return request(`${apiURL.api.changeMasterPwd}`, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}


export async function getBussinessList(params) {
  return request(apiURL.api.getBussinessList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function getBussinessDetail(params) {
  return request(`${apiURL.api.getBussinessDetail}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function addBussiness(params) {
  return request(apiURL.api.addBussiness, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function getDistrictListByBussiness(params) {
  return request(`${apiURL.api.getDistrictListByBussiness}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function getNetworkOperatorList(params) {
  return request(`${apiURL.api.getNetworkOperatorList}`, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function getPackagePage(params) {
  return request(apiURL.api.getPackagePage, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function addPackage(params) {
  return request(apiURL.api.addPackage, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function deletePackage(params) {
  return request(`${apiURL.api.deletePackage}/${params.id}`, {
    method: 'DELETE',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function updatePackage(params) {
  return request(apiURL.api.updatePackage, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function getDistrictList() {
  return request(apiURL.api.getDistrictList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: {
    },
  });
}
export async function getDistrictPage(params) {
  return request(apiURL.api.getDistrictPage, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function addDistrict(params) {
  return request(apiURL.api.addDistrict, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getworkerList() {
  return request(apiURL.api.getworkerList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: {
    },
  });
}
export async function getBussinessLists() {
  return request(apiURL.api.getBussinessLists, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: {
    },
  });
}
export async function getPackageInfo(params) {
  return request(`${apiURL.api.getPackageInfo}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function releasePackage(params) {
  return request(`${apiURL.api.releasePackage}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function checkPackage(params) {
  return request(`${apiURL.api.checkPackage}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function deleteDistrict(params) {
  return request(`${apiURL.api.deleteDistrict}/${params.id}`, {
    method: 'DELETE',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function getCommunityListByDistrict(params) {
  return request(apiURL.api.getCommunityListByDistrict, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getCommunityList(params) {
  return request(apiURL.api.getCommunityList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getDictionariesField(params) {
  return request(apiURL.api.getDictionariesField, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function updateDistrict(params) {
  return request(apiURL.api.updateDistrict, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getDistrictInfo(params) {
  return request(apiURL.api.getDistrictInfo, {
    method: 'DELETE',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getCommunityPage(params) {
  return request(apiURL.api.getCommunityPage, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function addCommunity(params) {
  return request(apiURL.api.addCommunity, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function deleteCommunity(params) {
  return request(`${apiURL.api.deleteCommunity}/${params.id}`, {
    method: 'DELETE',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getNetworkSpeedList(params) {
  return request(apiURL.api.getNetworkSpeedList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getProvincesList(params) {
  return request(apiURL.api.getProvincesList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function getWorkOrderList(params) {
  return request(apiURL.api.getWorkOrderList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getOrderStatusList() {
  return request(apiURL.api.getOrderStatusList, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function getWorkOrderDetail(params) {
  return request(`${apiURL.api.getWorkOrderDetail}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function orderComplete(params) {
  return request(`${apiURL.api.orderComplete}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function checkAndAssign(params) {
  return request(apiURL.api.checkAndAssign, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function assignMaster(params) {
  return request(apiURL.api.assignMaster, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}

export async function getPackageLists() {
  return request(apiURL.api.getPackageLists, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: {
    },
  });
}
export async function getPackageOrderList(params) {
  return request(apiURL.api.getPackageOrderList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getPackageOrderDetail(params) {
  return request(`${apiURL.api.getPackageOrderDetail}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}

export async function getUserBroadList(params) {
  return request(apiURL.api.getUserBroadList, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function getUserBroadDetail(params) {
  return request(`${apiURL.api.getUserBroadDetail}/${params.id}`, {
    method: 'GET',
    headers: {
      token: getAuthority(),
    },
  });
}
export async function updateAccountStatus(params) {
  return request(apiURL.api.updateAccountStatus, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function updateIsReward(params) {
  return request(apiURL.api.updateIsReward, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
export async function checkOrder(params) {
  return request(apiURL.api.checkOrder, {
    method: 'POST',
    headers: {
      token: getAuthority(),
    },
    body: params,
  });
}
